package org.tc.feign.shopmall.controller;

import Dto.OrdersDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.tc.feign.service.FeignOrdersdetailService2;
import org.tc.shopmall.entity.Orderdetails;

import java.util.List;

@CrossOrigin(origins = {"*"}, methods = {RequestMethod.GET, RequestMethod.POST}, allowCredentials = "true")
@RestController
public class OrderdetailsController {
    @Autowired
    private FeignOrdersdetailService2 orderdetailsService;

    @RequestMapping("/insertOrder")
    public int insertOrders(@RequestBody OrdersDto ordersDto) {
        System.out.println("添加");
        int save = orderdetailsService.insertOrder(ordersDto);
        return save;
    }

    @RequestMapping("/insertOrderdetails")
    public int insert(@RequestBody Orderdetails record) {
        int count = orderdetailsService.insert(record);
        return count;
    }

    @RequestMapping(value = "/selectAllOrderdetails")
    public List<Orderdetails> selectAll() {
        System.out.println("进入康除了");
        return orderdetailsService.selectAll();
    }

    @RequestMapping(value = "/selectOneOrderId")
    public Integer selectOneOrderId(){
        int orderId=orderdetailsService.selectOneOrderId();
        System.out.println(orderId);
        return orderId;
    }

    @RequestMapping("/deleteByIdOrderdetails")
    public int deleteById(@RequestParam Integer id, @RequestParam Integer commodityid) {
        return orderdetailsService.deleteById(id, commodityid);
    }

    @RequestMapping("/selectByIdOrderdetails")
    public Orderdetails selectById(Integer id) {
        return orderdetailsService.selectById(id);
    }
}



